--[[ 编码: hh-mobox-005 名称: 出入库业务 作者:SGX 日期:2024-11-27 函数: GenChartJson 功能: 叠折线图 更改记录: --]] json = require("json") mobox = require("OILua_JavelinExt") m3 = require("oi_base_mobox") function GenChartJson(strLuaDEID) local nRet, strRetInfo --[[ 标题颜色 ]] local strTitle = "出入库业务" --[[ 标题颜色 ]] local strColor = "#fff" --[[ 柱状图柱子名称,对应 series 下name ]] local tabLegendData = { '入库', '出库' } --[[ X轴数据 从左向右 ]] -- 获取当前日期 local current_time = os.time() local current_date = os.date("*t", current_time) local current_month = current_date.month local current_day = current_date.day local num = 7 local tabXAxis = {} local tabSeriesRKData = {} -- 入库数量 local tabSeriesCKData = {} -- 出库数量 for i = 1, 8 do local one_week_ago_time = current_time - num * 24 * 60 * 60 local one_week_ago_date = os.date("*t", one_week_ago_time) local one_week_ago_month = one_week_ago_date.month local one_week_ago_day = one_week_ago_date.day tabXAxis[i] = one_week_ago_month..'-'..one_week_ago_day -- 根据月份和天数获取入库任务数量 local count local strCondtion = "EXTRACT(MONTH FROM T_CREATE) = "..one_week_ago_month.." AND EXTRACT(DAY FROM T_CREATE) = "..one_week_ago_day.." AND S_OP_NAME IN('粉料入库','退料入库','国自空托回库','立库入库','保温材料入库')" nRet, count = mobox.getDataObjCount(strLuaDEID, "Task", strCondtion) if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "获取任务失败!"..count) end tabSeriesRKData[i] = count -- 根据月份和天数获取出库任务数量 strCondtion = "EXTRACT(MONTH FROM T_CREATE) = "..one_week_ago_month.." AND EXTRACT(DAY FROM T_CREATE) = "..one_week_ago_day.." AND S_OP_NAME IN('粉料出库','呼叫空托','采购退货','立库出库')" nRet, count = mobox.getDataObjCount(strLuaDEID, "Task", strCondtion) if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "获取任务失败!"..count) end tabSeriesCKData[i] = count num = num - 1 end tabXAxis[8] = current_month .. '-' .. current_day --[[ 入库颜色 ]] local strRKColor = '#EE822F' --[[ 出库颜色 ]] local strCKColor = '#F2BA02' --[[ 柱状图数据 对应X轴数据 ]] --[[入库 ]] -- local tabSeriesRKData = { 220, 182, 191, 234, 290, 330, 310, 400 } --[[ 出库]] -- local tabSeriesCKData = { 120, 132, 101, 134, 90, 230, 210, 300 } local option = { title = { text = strTitle, left = 20, textStyle = { color = strColor }, top = 10 }, tooltip = { trigger = 'axis', axisPointer = { type = 'cross', label = { backgroundColor = '#6a7985' } } }, legend = { data = tabLegendData, textStyle = { color = strColor }, top = 10 }, grid = { left = '5%', right = '5%', bottom = '5%', top = '18%', containLabel = true }, xAxis = { { type = 'category', boundaryGap = false, data = tabXAxis, axisLabel = { textStyle = { color = strColor } } } }, yAxis = { { type = 'value', axisLabel = { textStyle = { color = strColor } } } }, series = { { name = '入库', type = 'line', stack = 'Total', areaStyle = {}, emphasis = { focus = 'series' }, label = { show = true }, color = strRKColor, data = tabSeriesRKData }, { name = '出库', type = 'line', stack = 'Total', areaStyle = {}, emphasis = { focus = 'series' }, label = { show = true }, color = strCKColor, data = tabSeriesCKData } } } local action = {} action[1] = { action_type = "chart", value = { graphicType = "echart", title = { text = strTitle, align = "center", color = "#515a6e", font = "微软雅黑", fontSize = 12 }, option = option } } nRet, strRetInfo = mobox.setAction(strLuaDEID, lua.table2str(action)) if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "setAction失败! " .. strRetInfo) end end